﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;

namespace ManiaDown.SayoApi
{
    class Beatmap
    {
        public string Artist { get; set; }
        public string Creator { get; set; }
        public string Title { get; set; }
        public int Sid { get; set; }
        public Beatmap() { }

        public void Download()
        {

        }

        public static Beatmap Parase(JObject jobject)
        {
            try
            {
                var result = new Beatmap
                {
                    Artist = jobject["artist"].ToString(),
                    Creator = jobject["creator"].ToString(),
                    Title = jobject["title"].ToString(),
                    Sid = Convert.ToInt32(jobject["sid"].ToString())
                };
                return result;
            }
            catch
            {
                throw new ArgumentException("该JObject对象无法转换为Beatmap");
            }
        }

        public override string ToString() => @$"{Artist} - {Creator} - {Title}";
    }
}
